import 'dart:convert';

/// 课程
class Course {
  String id,
      createDate,
      courseName,
      courseUrl,
      courseSpeaker,
      courseLecturer,
      courseRanking,
      courseVideoImg,
      courseVideo,
      courseCategory,
      courseComment,
      whetherAppointed;

  Course({
    this.id,
    this.createDate,
    this.courseName,
    this.courseUrl,
    this.courseSpeaker,
    this.courseLecturer,
    this.courseRanking,
    this.courseVideoImg,
    this.courseVideo,
    this.courseCategory,
    this.courseComment,
    this.whetherAppointed,
  });

  factory Course.fromJson(Map<String, dynamic> data) {
    return Course(
      id: data['id'],
      createDate: data['createDate'],
      courseName: data['courseName'],
      courseUrl: data['courseUrl'],
      courseSpeaker: data['courseSpeaker'],
      courseLecturer: data['courseLecturer'],
      courseRanking: data['courseRanking'],
      courseVideoImg: data['courseVideoImg'],
      courseVideo: data['courseVideo'],
      courseCategory: data['courseCategory'],
      courseComment: data['courseComment'],
      whetherAppointed: data['whetherAppointed']?.toString(),
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'createDate': createDate,
      'courseName': courseName,
      'courseUrl': courseUrl,
      'courseSpeaker': courseSpeaker,
      'courseLecturer': courseLecturer,
      'courseRanking': courseRanking,
      'courseVideoImg': courseVideoImg,
      'courseVideo': courseVideo,
      'courseCategory': courseCategory,
      'courseComment': courseComment,
      'whetherAppointed': whetherAppointed,
    };
  }

  @override
  String toString() {
    return json.encode(toJson());
  }
}
